package com.itheima.charstream1;

import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;

public class CharStreamDemo2 {
    public static void main(String[] args) throws UnsupportedEncodingException {
//        method1();
        // UTF-8
        byte[] bytes1 = {-23, -69, -111, -23, -87, -84, -25, -88, -117, -27, -70, -113, -27, -111, -104};
        byte[] bytes2 = {-70, -38, -62, -19, -77, -52, -48, -14, -44, -79};

        String s1 = new String(bytes1);
        System.out.println(s1);
        String s2 = new String(bytes2, "GBK");
        System.out.println(s2);
    }

    private static void method1() throws UnsupportedEncodingException {
        String s = "黑马程序员";
        byte[] bytes1 = s.getBytes();
        System.out.println(Arrays.toString(bytes1));

        byte[] bytes2 = s.getBytes(StandardCharsets.UTF_8);
        System.out.println(Arrays.toString(bytes2));

        byte[] bytes3 = s.getBytes("GBK");
        System.out.println(Arrays.toString(bytes3));
    }
}
